//ios风格的路由
import 'package:app/pages/constellations_list/main.dart';
import 'package:app/pages/index.dart';
import 'package:app/pages/mechat/forgot.dart';
import 'package:app/pages/mechat/home.dart';
import 'package:app/pages/mechat/index.dart';
import 'package:app/pages/mechat/login.dart';
import 'package:app/pages/mechat/register.dart';
import 'package:app/pages/mechat/search.dart';
import 'package:app/pages/tem_bubble_tab_bar/main.dart';
import 'package:flutter/cupertino.dart';
import 'package:app/pages/tabs/tabs.dart';
import 'package:app/pages/login.dart';
import 'package:app/pages/tem/main.dart';

import '../pages/dark_ink_transition/main.dart';
import '../pages/tem_basketball/main.dart';

//1、配置路由

// Map routes = {
//   // "/": (contxt) => const Index(),
//   "/": (contxt) => const Onload(),
// };

StatefulWidget Function(dynamic contxt) routes(url) {
  print(url);
  switch (url) {
    case "/":
      return (contxt) => const Index();
    case "/tab":
      return (contxt) => const Tabs();
    case "/login":
      return (contxt) => const LoginPage();
    case "/tem1":
      return (contxt) => const TemPage();
    case "/temBasketball":
      return (contxt) => const TemBasketballPage();
    case "/TemBubbleTabBar":
      return (contxt) => const TemBubbleTabBar();
    case "/TemConstellationsList":
      return (contxt) => const TemConstellationsList();
    case "/TemInkTransition":
      return (contxt) => const TemInkTransition();
    case "/TemMechat":
      return (contxt) => const IndexPage();
    case "/mechat/login":
      return (contxt) => const MechatLogin();
    case "/mechat/register":
      return (contxt) => const MechatRegister();
    case "/mechat/forgot":
      return (contxt) => const MechatForgot();
    case "/mechat/home":
      return (contxt) => const MechatHomePage();
    case "/mechat/search":
      return (contxt) => const MechatSearch();

    default:
      return (contxt) => const Tabs();
  }
}

//2、配置onGenerateRoute  固定写法  这个方法也相当于一个中间件，这里可以做权限判断
var onGenerateRoute = (RouteSettings settings) {
  final String? name = settings.name;
  final Function pageContentBuilder = routes(name);
  //  Function = (contxt) { return const NewsPage()}

  if (settings.arguments != null) {
    final Route route = CupertinoPageRoute(
        builder: (context) =>
            pageContentBuilder(context, arguments: settings.arguments));
    return route;
  } else {
    final Route route =
        CupertinoPageRoute(builder: (context) => pageContentBuilder(context));

    return route;
  }
};
